﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class TrackPackage : BasePage
{
    BLLTrackPackage bllTrackPackage = new BLLTrackPackage();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["barcode"] != null)
            {
                string barcode = Request.QueryString["barcode"];
                bindPackages(barcode);
            }
        }
    }

    private void bindPackages()
    {

    }

    private void bindPackages(string barcode)
    {
        dlPackage.DataSource = new List<vPackageDetail>() { bllTrackPackage.GetvPackage(barcode) };
        dlPackage.DataBind();
    }

    protected void btnCheck_Click(object sender, EventArgs e)
    {
        bindPackages(txtBarcode.Text.Replace("+",""));
    }

    protected void dlPackage_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        vPackageDetail detail = e.Item.DataItem as vPackageDetail;
        if (detail != null)
        {
            DataList dl = e.Item.FindControl("dlTransit") as DataList;
            if (dl != null)
            {
                dl.DataSource = bllTrackPackage.GetvPackageTransits(detail.ID);
                dl.DataBind();
            }
        }
    }
}